package org.jeecg.modules.online.low.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.online.low.entity.LowApp;
import org.jeecg.modules.online.low.mapper.LowAppMapper;
import org.jeecg.modules.online.low.service.ILowAppService;
import org.springframework.stereotype.Service;

/**
 * @Description: low_app
 * @Author: jeecg-boot
 * @Date: 2021-07-13
 * @Version: V1.0
 */
@Service("lowAppServiceImpl")
public class LowAppServiceImpl extends ServiceImpl<LowAppMapper, LowApp> implements ILowAppService {

    @Override
    public boolean createApp(LowApp lowApp) {
        lowApp.setAppLabel("");
        Integer maxOrderNum = baseMapper.selectLabelMaxOrderNum("");
        if (maxOrderNum == null) {
            lowApp.setOrderNum(0);
        } else {
            lowApp.setOrderNum(maxOrderNum + 1);
        }
        return super.save(lowApp);
    }

    @Override
    public boolean moveToGroup(LowApp lowApp) {
        Integer maxOrderNum = baseMapper.selectLabelMaxOrderNum(lowApp.getAppLabel());
        if (maxOrderNum == null) {
            lowApp.setOrderNum(0);
        } else {
            lowApp.setOrderNum(maxOrderNum + 1);
        }
        return super.updateById(lowApp);
    }

}
